%{

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "y.tab.h"
%}

/* definicoes regulares */
letter                  [A-Za-z]
digit                   [0-9]
id                      {letter}({letter}|{digit})*
number                  {digit}+(\.{digit}+)?(E[+-]?{digit}+)?

%%
program                 {return PROGRAM;}
begin                   {return BEGIN_;}
end                     {return END;}
declare                 {return DECLARE;}
integer                 {return INTEGER;}
boolean                 {return BOOLEAN;}
char                    {return CHAR;}
label                   {return LABEL;}
real                    {return REAL;}
array                   {return ARRAY;}
of                      {return OF;}
procedure               {return PROCEDURE;}
if                      {return IF;}
then                    {return THEN;}
else                    {return ELSE;}
while                   {return WHILE;}
do                      {return DO;}
read                    {return READ;}
write                   {return WRITE;}
goto                    {return GOTO;}
return                  {return RETURN;}
not                     {return NOT;}
or                      {return OR;}
and                     {return AND;}
mod                     {return MOD;}
false                   {return FALSE;}
true                    {return TRUE;}
">="                    {return GE;} 
"!="                    {return NE;} 
":="                    {return ASSIGN;} 

">"|"<"|"="|";"|":"|"," {return (int)yytext[0];}
"("|")"|"["|"]"         {return (int)yytext[0];}
"'"|"+"|"-"|"*"|"/"     {return (int)yytext[0];}

[ \n]+                
{digit}                 {return (int)yytext[0];}
{number}                {yylval.number=atoi(yytext);return NUMBER;}
{id}                    {yylval.string=strdup(yytext);return ID;}
"'"."'"                 {yylval.number=(int)yytext[1];return CHARACTER;}

%%

